package com.shanks.home.module.media;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.shanks.home.R;

public class MediaActivity extends Activity {
	
	private Context context;
	private Button mediaplayerBtn, soundpoolBtn;
	private ShanksSoundPool shanksSoundPool;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		context = this;
		this.setContentView(R.layout.activity_media);
		initView();
		initOther();
	}
	
	private void initView() {
		mediaplayerBtn = (Button)this.findViewById(R.id.media_mediaplayer_btn);
		soundpoolBtn = (Button)this.findViewById(R.id.media_soundpool_btn);
		
		mediaplayerBtn.setOnClickListener(onClickListener);
		soundpoolBtn.setOnClickListener(onClickListener);
	}
	
	private void initOther() {
		shanksSoundPool = ShanksSoundPool.getInstance(context);
	}
	
	private OnClickListener onClickListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			int id = v.getId();
			if (id == R.id.media_mediaplayer_btn) {
				new ShanksMediaPlayer(context);
			} else if (id == R.id.media_soundpool_btn) {
				shanksSoundPool.play();
			}
		}
	};
}